package org.sample.springboot.service;

import java.util.Date;
import java.util.Random;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

@Service
public class DateTimeService {

	private static final Logger LOGGER = LoggerFactory.getLogger(DateTimeService.class);

	private Random random = new Random();

	public String getDateTime() {

		int interval = random.nextInt(10000);
		LOGGER.debug("Thread sleep interval: {}", interval);

		try {
			Thread.sleep(interval);
		} catch (InterruptedException ex) {
			LOGGER.warn("Thread is interrupted", ex);
		}

		return new Date().toString();
	}

}